//
//  TTBaseViewController.swift
//  NewWeiBo
//
//  Created by 吴天益 on 2017/7/22.
//  Copyright © 2017年 ttt. All rights reserved.
//

import UIKit

class TTBaseViewController: UIViewController {
    
    var logIn: Bool = TTUserAccountViewModel.shareViewModel.isLogin
    
    var visitView: NotView?
    
    //自定义loadView,自定义控制器试图
    override func loadView() {
        if logIn == true{
            super.loadView()
        }else{
            //未登录时自定义控制器试图
            visitView = NotView()
            
            //为block赋值
            visitView?.logInBlock = {[unowned self] in
                self.dengLu()
            }
            visitView?.logUpBlock = {[unowned self] in
                self.zhuCe()
            }
            
            view = visitView
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
//        view.backgroundColor = UIColor.white
        
        navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "注册", target: self, action: #selector(zhuCe))
        
            navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "登陆", target: self, action: #selector(dengLu))
        
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .done, target: self, action: #selector(popController))
//        
//        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .done, target: self, action: #selector(turnToANewController))
//        
//        navigationController?.navigationBar.tintColor = UIColor.darkGray

    }

    
    
    //MARK:
    //MARK: -- 登陆按钮点击方法
    func zhuCe(){
        print("注册")
    }
    
    //MARK:
    //MARK: -- 注册item点击方法
    func dengLu(){
        print("登陆")
        
        //调转登陆控制器
//        navigationController?.pushViewController(TTOAuthViewController(), animated: true)
        let navi = TTNavigationController(rootViewController: TTOAuthViewController())
        
        self.present(navi, animated: true, completion: nil)
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
